package models

import (
	"gorm.io/gorm"
	"login-guard/loginrpc/loginrpc"
)

type User struct {
	gorm.Model
	Username string `gorm:"type:varchar(50);not null;comment:'账号'"`
	Password string `gorm:"type:varchar(50);not null;comment:'密码'"`
}

func (u *User) LoginUser(db *gorm.DB) error {
	return db.Create(u).Error
}

func (u *User) Users(db *gorm.DB, in *loginrpc.LoginsRequest) error {
	return db.Model(&User{}).Where("username= ?", in.Username).First(u).Error
}
